package demo;

abstract class Shape{

    //抽象类加上abstract 就可以不写具体的实现了
    //也可以有具体的实现，那样就不加abstract
    public abstract void draw();
}

class Rect extends Shape {
    //当一个普通类继承了一个抽象类，必须重写抽象类中的抽象方法
    @Override
    public void draw() {
        System.out.println("画矩形！");
    }
}
class Cycle extends Shape {
    @Override
    public void draw() {
        System.out.println("画圆形！");
    }
}
class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("画花！");
    }
}

public class Text2 {
    public static void drawMap(Shape shape){
        shape.draw();
    }

    public static void main(String[] args) {
/*        在抽象类中不能实例化对象
        Shape shape = new Shape();  */
        drawMap(new Rect());
        drawMap(new Cycle());
        drawMap(new Flower());
    }
}
